{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9130bef4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(196, 120)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "#mouese callback function\n",
    "def draw_rectangle(event,x,y,flags,param):\n",
    "    if event == cv.EVENT_LBUTTONDBLCLK:\n",
    "        startPt = (x,y)\n",
    "        endPt = (x+100,y+200)\n",
    "        color = (0,255,0)\n",
    "        thinknessPx = -1\n",
    "        cv.rectangle(img,startPt,endPt,color,thinknessPx)\n",
    "        print((x,y))\n",
    "    \n",
    "#def draw_circle(event,x,y,flags,param):\n",
    "#   if event == cv.EVENT_LBUTTONDBLCLK:\n",
    "#        cv.circle(img,(x,y),100,(255,0,0),-1)\n",
    "#        print((x,y))\n",
    "        \n",
    "#creat a black image\n",
    "#a window and bind the function to window\n",
    "img = np.zeros((512,512,3),np.uint8)\n",
    "cv.namedWindow('image')\n",
    "cv.setMouseCallback('image',draw_rectangle)\n",
    "\n",
    "while(1):\n",
    "    cv.imshow('image',img)\n",
    "    if cv.waitKey(20) & 0xFF == 27:\n",
    "        break\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71dad5a4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
